package office.dao.hr;

import platform.common.dao.impl.BaseDomainProviderImpl;

public class CarriageEntryDP extends BaseDomainProviderImpl{

	//String id,String entryUser,String useStartDate,String useEndDate,
	//String reason,String remark,String state,String carriageId,String entryUserName
	public String getFindByUserId(){
		return "select new office.action.hr.wrapper.CarriageEntryWrapper(a.id,a.entryUser,a.useStartDate," +
				"a.useEndDate,a.reason,a.remark,a.state,b.cname,a.carriageId) from " + this.getDomainClassName()
				+" a,User b where a.entryUser = b.id and (a.entryUser=:userId or a.checkUesr=:userId)";
	}
	
	public String getFindByUserId2(){
		return "SELECT a.id,a.entryuser,a.usestartdate,a.useenddate," +
				"a.reason,a.state,c.cname,a.carriageid,b.carriagecode" +
				" from tbl_carriageentry a JOIN tbl_user c ON a.entryuser=c.id " +
				"LEFT JOIN tbl_carriagemanage b ON a.carriageid=b.id " +
				"WHERE a.entryuser=:userId AND a.checkuesr=:userId";
	}
	
	public String getFindByUserIdAndCarriage(){
		return "select new office.action.hr.wrapper.CarriageEntryWrapper(a.id,a.entryUser,a.useStartDate," +
				"a.useEndDate,a.reason,a.remark,a.state,a.carriageId,b.cname,c.carriageCode) from " + this.getDomainClassName()
				+" a,User b,CarriageManage c where a.entryUser = b.id and a.carriageId = c.id and (a.entryUser=:userId or a.checkUesr=:userId)";
	}
	
	/**
	 * 获取某时间是否存在申请使用车辆
	 * @return
	 */
	public String getFindByDate(){
		return "from "+ this.getDomainClassName()+" where useStartDate>=:useStartDate and useEndDate<=:useEndDate and state=1 and carriageId=:carriageId";
	}
}
